import { Sequelize, Dialect } from "sequelize";

import { db } from "../common/config";

// 数据库实例
export default new Sequelize(
  db.database,
  db.username,
  db.password,
  {
    host: db.host,
    port: db.port,
    dialect: db.dialect as Dialect,
    define: {
      engine: "InnoDB",
      freezeTableName: true
    },
    timezone: "+08:00",
    logging: (message) => {
      if (process.env.DEBUG === "true") {
        console.log(message);
      }
    }
  }
);
